//
//  ImageUpload2Server.m
//  beautyLamp
//
//  Created by Tam Kwok To Michael on 2017/8/16.
//  Copyright © 2017年 Tam Kwok To Michael. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "ImageUpload2Server.h"
#import "BasicNetManager.h"
#import "BLHeader.h"

@implementation ImageUpload2Server

+ (void)postImage:(UIImage *) image completer:(void(^)(id resultObject, NSError *error)) completer{
    BasicNetManager *manager = [BasicNetManager share];
    NSString *tel = [[NSUserDefaults standardUserDefaults] objectForKey:USERTEL];
    NSData *imageData = UIImagePNGRepresentation(image);
    NSString *str = [imageData base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];
    NSDictionary *param = @{@"userTel":tel,@"imgDecode":str};    
    [manager postURL:UPLOADIMAGE param:param completer:^(id result, NSError *error) {
        if(completer) {
            if (result) {
                [[NSUserDefaults standardUserDefaults] setObject:[result objectForKey:@"userImg"] forKey:USERIMG];
            }
            completer(result, error);
        }
    }];
}

@end
